// components/dynamic_items/index.js

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    dynamiclist: {
      type: Array,
      value:[]
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    goDynamicDetail(e){
      let id = e.currentTarget.dataset.id
      wx.navigateTo({
        url: `/pages/dynamicDetail/index?id=${id}`
      })
    },
    changelike(e){
      let index = e.currentTarget.dataset.index
      let like = e.currentTarget.dataset.like
      let dynamiclist = this.properties.dynamiclist
      dynamiclist[index].like = !like
      this.setData({
        dynamiclist:dynamiclist
      })
      wx.cloud.init({env: 'cloud1-5glocnmp62950062'})
      wx.cloud.callFunction({
        name: 'changeLove',
        data:{
          dynamicid: dynamiclist[index]._id
        },
        success: res=>{
          console.log(res)
        },
        complete: res=>{
  
        }
      })
    }
  }
})
